/*
 * spieeprom.h
 *
 *  Created on: Nov 11, 2013
 *      Author: Ahmed
 */

#ifndef SPIEEPROM_H_
#define SPIEEPROM_H_

/*
  	WREN 	Write Enable 			0000 0110
	WRDI 	Write Disable 			0000 0100
	RDSR 	Read Status Register 	0000 0101
	WRSR 	Write Status Register 	0000 0001
	READ 	Read from Memory Array 	0000 0011
	WRITE 	Write to Memory Array 	0000 0010
 */
#define cmdREAD 	0x03
#define cmdWRITE	0x02
#define cmdWREN		0x06
#define cmdWRDI		0x04
#define cmdRDSR		0x05
#define cmdWRSR		0x01

#define	DUMMY_BYTE	0xff
#define	spiEE_PAGESIZE	64

void SPI1_configuration(void);
void CS_LOW(void);
void CS_HIGH(void);
uint8_t spi_WriteByte(uint8_t);
uint8_t spi_ReadByte(void);
uint8_t spi_SendCmd(uint8_t, uint8_t);
void spiEE_Read(uint8_t*, uint16_t, uint16_t);
void spiEE_WriteAcrossPages(uint8_t*, uint16_t, uint16_t);
void spiEE_WriteWithinPage(uint8_t*, uint16_t, uint16_t);
void spiEE_WaitEepromWIP(void);

#endif /* SPIEEPROM_H_ */
